package com.chen.cachetest.service.impl;

import com.chen.cachetest.entity.User;
import com.chen.cachetest.repository.UserRepository;
import com.chen.cachetest.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheConfig;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

@Service
@CacheConfig(cacheNames = "userCache")
public class UserServiceImpl implements IUserService {

    @Autowired
    private UserRepository userRepository;


    @Cacheable(key = "#name")
    @Override
    public User findUserBuName(String name) {
        return userRepository.findByName(name);
    }
}
